<div class="page-content">
    <!-- BEGIN PAGE HEADER-->
	<div class="row">
		<div class="col-md-12">
			<!-- BEGIN PAGE TITLE & BREADCRUMB-->
			<h3 class="page-title">
		          Edit Menu
			</h3>
			<ul class="page-breadcrumb breadcrumb">
				<li>
					<i class="fa fa-home"></i>
					<a href="<?php echo $this->Admin->admin_url() ?>">
						Home
					</a>
					<i class="fa fa-angle-right"></i>
				</li>
				<li>
					<a href="<?php echo $this->Admin->admin_url() ?>menu/index">
						Menu list
					</a>
					<i class="fa fa-angle-right"></i>
				</li>
				<li>
					<a href="javascript:void(0)">
						Edit Menu
					</a>
				</li>
			</ul>
			<!-- END PAGE TITLE & BREADCRUMB-->
		</div>
	</div>
	<!-- END PAGE HEADER-->
	<!-- BEGIN PAGE CONTENT-->
    <div class="row">
        <div class="col-md-12">
        	<!-- BEGIN VALIDATION STATES-->
        	<div class="portlet box blue">
        		<div class="portlet-title">
        			<div class="caption">
        				<i class="fa fa-reorder"></i>Managed table
        			</div>
        		</div>
        		<div class="portlet-body form">
        			<!-- BEGIN FORM-->
        			<!--form action="" id="form_category" class="form-horizontal" method="post"-->
                    <?php
                        echo $this->Form->create('Menu', array(
                                                            'url' => array('controller' => 'menu', 'action' => 'edit', $menu_id, $parent_id), 
                                                            'type' => 'post',
                                                            'id' => 'form_menu',
                                                            'class' => 'form-horizontal'));
                    ?>
                        <input type="hidden" name="menu_id" value="<?php echo $menu_id ?>" />
        				<div class="form-body">
                            <div class="form-group">
        						<label class="control-label col-md-3">Menu parent
        						</label>
        						<div class="col-md-4">
                                    <select id="" class="form-control select2me" name="parent_id">
                                        <option value="0">Choose one menu</option>
                                        <?php
                                            foreach($list_menu as $menu)
                                            {
                                                $selected = $menu_info['menu']['parent_id'] == $menu['menu_id'] ? "selected='selected'" : "";
                                                $level = $menu['level'];
                                                $span = "";
                                                for($j = 0; $j < $level; $j++)
                                                    $span .= '--&nbsp&nbsp';
                                                echo '<option '.$selected.' value="'.$menu['menu_id'].'">'.$span.$menu['title'].'</option>';
                                            }
                                        ?>
                                    </select>
        						</div>
        					</div>
                            <div class="form-group">
        						<label class="control-label col-md-3">Status
                                    <span class="required">*</span>
        						</label>
        						<div class="col-md-4">
                                    <div class="radio-list">
										<?php
                                            $checkEnable = "";
                                            $checkDisable = "";
                                            if($menu_info['menu']['status'] == 1)
                                                $checkEnable = 'checked="checked"';
                                            else
                                                $checkDisable = 'checked="checked"';
                                        ?>
                                        <label>
										<input <?php echo $checkEnable ?> type="radio" name="status" value="1"/>
										Enable </label>
										<label>
										<input <?php echo $checkDisable ?> type="radio" name="status" value="0"/>
										Disable </label>
									</div>
        						</div>
        					</div>
                            <div class="form-group">
        						<label class="control-label col-md-3">Menu code
                                    <span class="required">*</span>
        						</label>
        						<div class="col-md-4">
                                   <?php
                                   /*
                                        echo $this->Form->input('menu_code',
                                                                        array(
                                                                            'label' => false,
                                                                            'div' => false,
                                                                            'class' => 'form-control',
                                                                            'value' => $menu_info['menu']['menu_code']
                                                                        )
                                                        );
                                   */
                                   ?>
                                   <input type="text" id="menu_code" class="form-control" name="data[Menu][menu_code]" value="<?php echo $menu_info['menu']['menu_code'] ?>" />
        						</div>
        					</div>
                            <div class="form-group">
        						<label class="control-label col-md-3">Sort order
                                 </label>
        						<div class="col-md-4">
                                    <?php
                                        echo $this->Form->text('sort_order',
                                                        array(
                                                            'label' => false,
                                                            'div' => false,
                                                            'class' => 'form-control',
                                                            'value' => $menu_info['menu']['sort_order']
                                                        )
                                        );
                                    ?>
        						</div>
        					</div>
                            
                            <div class="form-group">
        						<label class="control-label col-md-3">Other
                                </label>
        						<div class="col-md-9">
                                    <?php
                                        echo $this->Form->input('other',
                                                        array(
                                                            'label' => false,
                                                            'div' => false,
                                                            'class' => 'form-control',
                                                            'rows' => 1,
                                                            'value' => $menu_info['menu']['other']
                                                        )
                                        );
                                    ?>
        						</div>
        					</div>
                            
                            <?php
                                $main_image = 'images/no-image.jpg';
                                if(!empty($list_image))
                                {
                                    $main_image = isset($list_image['main_image']['name']) ? $list_image['main_image']['name'] : $main_image;
                                }
                            ?>
                            <div class="form-group">
        						<label class="control-label col-md-3">Image&nbsp;&nbsp;</label>
        						<div class="col-md-4">
                                    <div class="btn-group btn-group-xs btn-group-solid">
                                        <img id="main_image" class="show_image_browse" src="<?php echo $this->webroot ?><?php echo $main_image ?>" />
                                        <input class="main_image" type="hidden" name="main_image" value="<?php echo $this->webroot ?><?php echo $main_image ?>" />
                                        <div class="clear"></div>
                                        <button class="btn blue fileBrowse" data-target="main_image" type="button">Browse File</button>
										<button class="btn red fileDelete" data-target="main_image" type="button">Delete File</button>
                                    </div>
                                </div>
        					</div>
    
    
                            <div class="">
        						<label class="control-label col-md-3"></label>
        						<div class="col-md-9">
                        			<div class="tabbable tabbable-custom">
                        				<ul class="nav nav-tabs">
                                            <?php
                                                $i=0;
                                                foreach($list_language as $language)
                                                {
                                                    $language = $language['language'];
                                                    $lang_code = $language['lang_code'];
                                            ?>
                        					<li class='<?php echo $i++==0 ? "active" : "" ?>'>
                        						<a data-toggle="tab" href="#tab_<?php echo $lang_code ?>">
                        							 <img src="<?php echo $this->webroot; ?>admin/img/flags/<?php echo $lang_code ?>.png" />
                                                     <?php echo $language['title'] ?>
                        						</a>
                        					</li>
                                            <?php
                                                }
                                            ?>
                        				</ul>
                        				<div class="tab-content">
                                            <?php
                                                $i = 0;
                                                foreach($list_language as $language)
                                                {
                                                    $language = $language['language'];
                                                    $lang_code = $language['lang_code'];
                                            ?>
                                            <div id="tab_<?php echo $lang_code ?>" class="tab-pane <?php echo $i++==0 ? "active" : "" ?>">
                                                <div class="form-group">
                            						<label class="control-label mgl15">Title
                                                        <span class="required">*</span>
                            						</label>
                            						<div class="col-md-12 error-title">
                                                    <!--
                            							<input type="text" id="title_<?php echo $lang_code ?>" name="title_<?php echo $lang_code ?>" data-required="1" class="form-control" value="<?php echo $menu_info['menu_desc'][$lang_code]['title'] ?>"/>
                            						-->
                                                    <?php
                                                        echo $this->Form->input('title_'.$lang_code,
                                                                        array(
                                                                            'label' => false,
                                                                            'div' => false,
                                                                            'class' => 'form-control',
                                                                            'id' => 'title_'.$lang_code,
                                                                            'value' => $menu_info['menu_desc'][$lang_code]['title']
                                                                        )
                                                        );
                                                    ?>
                                                    </div>
                            					</div>
                                                <div class="form-group">
                            						<label class="control-label mgl15">Link
                                                        <span class="required">*</span>
                            						</label>
                            						<div class="col-md-12">
                                                    <?php
                                                        echo $this->Form->input('link_'.$lang_code,
                                                                        array(
                                                                            'label' => false,
                                                                            'div' => false,
                                                                            'class' => 'form-control',
                                                                            'id' => 'link_'.$lang_code,
                                                                            'value' => $menu_info['menu_desc'][$lang_code]['link']
                                                                        )
                                                        );
                                                    ?>
                                                    </div>
                            					</div>
                                                <!--END_INPUT_FORM-->
                                                <div class="form-group">
                            						<label class="control-label mgl15">
                                                        Short description
                            						</label>
                            						<div class="col-md-12">
                            							<textarea id="description_<?php echo $lang_code ?>" class="form-control" name="description_<?php echo $lang_code ?>" rows="6"><?php echo $menu_info['menu_desc'][$lang_code]['description'] ?></textarea>
                            						</div>
                            					</div>
                                                <!--END_INPUT_FORM-->
                                                <div class="clearfix"></div>
                        					</div>
                        					<!--end tab-pane-->
                                            <?php
                                                }
                                            ?>
                        					<!--end tab-pane-->
                                            <div class="clearfix"></div>
                        				</div>
                                        
                        			</div>
                        		</div>
        					</div>
                            <div class="clearfix"></div>
        				</div>
        				<div class="form-actions fluid">
        					<div class="col-md-offset-3 col-md-9">
                                <button type="submit" class="btn blue" name="btn_submit" value="ok">Submit</button>
        						<button onclick="window.location.href = '<?php echo $this->Admin->admin_url() ?>menu/index/<?php echo $parent_id ?>'" type="button" class="btn default">Cancel</button>
        					</div>
        				</div>
                        
        			<?php echo $this->Form->end(); ?>
        			<!-- END FORM-->
        		</div>
        		<!-- END VALIDATION STATES-->
        	</div>
        </div>
    </div>
</div>

                    
                    
<!-- END CONTENT -->

<script type="text/javascript" src="<?php echo $this->webroot; ?>ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="<?php echo $this->webroot; ?>ckfinder/ckfinder.js"></script>

<script>
    <?php
        foreach($list_language as $language)
        {
            $language = $language['language'];
            $lang_code = $language['lang_code'];
    ?>
        var description_<?php echo $lang_code ?> = CKEDITOR.replace('description_<?php echo $lang_code ?>');
        CKFinder.setupCKEditor( description_<?php echo $lang_code ?>, '<?php echo $this->webroot ?>ckfinder/' );
    <?php
        }
    ?>
</script>